

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>表单组合</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/layuikn/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/layuikn/style/admin.css" media="all">
</head>

<style>
    #gerenbingshi .layui-form-checkbox{
        margin-top: 10px;
    }
</style>

<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header"><h2>个人信息</h2></div>
        <div class="layui-card-body" style="padding: 15px;">

            <form class="layui-form" action="" lay-filter="component-form-group">
                <fieldset class="layui-elem-field" style="padding: 20px;">
                    <legend style="font-size: 15px;">个人资料 - 各项资料都必须填写</legend>
                    <div class="layui-row">
                        <div style="font-weight: 600;">1、基本资料</div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">调查号</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="title" readonly autocomplete="off" placeholder="请输入标题"  value="{if isset($info['bianhao'])}{$info['bianhao']}{else /}自动生成{/if}" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">姓名</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['name'])}{$info['name']}{/if}" type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入姓名"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">出生日期</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['birthday'])}{$info['birthday']}{/if}" type="text" name="birthday" lay-verify="required" readonly id="birthday" autocomplete="off" placeholder="请输入出生日期"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">入院时间</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['rydate'])}{$info['rydate']}{/if}" type="text" name="rydate" lay-verify="required" id="rydate" readonly autocomplete="off" placeholder="请输入入院时间"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-col-md12">
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">性别</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="gender" value="男" title="男" {if isset($info['gender']) && $info['gender']=='男'}checked{/if}>
                                        <input type="radio" name="gender" value="女" title="女"  {if isset($info['gender']) && $info['gender']=='女'}checked{/if}>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">是否绝经</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="is_juejing" value="1" title="是" {if isset($info['is_juejing']) && $info['is_juejing']==1}checked{/if}>
                                        <input type="radio" name="is_juejing" value="2" title="否" {if isset($info['is_juejing']) && $info['is_juejing']==2}checked{/if}>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <div class="layui-input-block" style="margin-left: 50px;">
                                        <input type="radio" name="juejing" value="人工绝经" title="人工绝经" {if isset($info['juejing']) && $info['juejing']=='人工绝经'}checked{/if}>
                                        <input type="radio" name="juejing" value="自然绝经" title="自然绝经"  {if isset($info['juejing']) && $info['juejing']=='自然绝经'}checked{/if}>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">住院号</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['hospital_id'])}{$info['hospital_id']}{/if}" type="text" name="hospital_id" lay-verify="required" autocomplete="off" placeholder="请输入住院号" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">医院</label>
                                    <div class="layui-input-block">
                                        <select name="yyid" lay-verify="required" disabled>
                                            <option value="{$hospital.id}" selected>{$hospital.name}</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md3">
                                <label class="layui-form-label">科室</label>
                                <div class="layui-input-block">
                                    <select name="ksid" lay-verify="required">
                                        {volist name="keshi.children" id="data" key="i" }
                                        <option value="{$data.id}" {if isset($info['ksid']) && $info['ksid']== $data.id}selected{/if} >{$data.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">2、个人病史（可多选）</div>
                        <div class="layui-col-md12" >
                            <div class="layui-input-block" style="margin-left: 50px;" id="gerenbingshi">
                                <input hidden value="{if isset($info['bingshi'])}{$info['bingshi']}{/if}" type="text" name="bingshi" value="" disabled>
                                {volist name="gerenbingshi.children" id="data" key="i" }
                                <input type="checkbox" lay-filter="bingshi" value="{$data.id}" title="{$data.name}">
                                {/volist}
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">3、肿瘤家族史</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <label class="layui-form-label" style="width: 200px;">三代内直系亲属有无恶性肿瘤</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="is_zljzs" value="有" title="有" {if isset($info['is_zljzs']) && $info['is_zljzs']=='有'}checked{/if}>
                                    <input type="radio" name="is_zljzs" value="无" title="无" {if isset($info['is_zljzs']) && $info['is_zljzs']=='无'}checked{/if}>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div style="font-weight: 600;">4、生活习惯</div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 420px;">
                                        <span style="margin-right: 30px;">（1）吸烟</span>在您的一生中，累积吸烟是否超过5包（20支/包）
                                    </label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="xiyan" value="是" title="是" {if isset($info['xiyan']) && $info['xiyan']=='是'}checked{/if}>
                                        <input type="radio" name="xiyan" value="否" title="否" {if isset($info['xiyan']) && $info['xiyan']=='否'}checked{/if}>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        平均每周（7天）吸烟
                                        <input value="{if isset($info['xiyan_nums'])}{$info['xiyan_nums']}{/if}" type="text"  name="xiyan_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        包，持续
                                        <input value="{if isset($info['xiyan_year'])}{$info['xiyan_year']}{/if}" type="text"  name="xiyan_year" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        年

                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 100px;margin-left: 50px;">
                                        患者目前为
                                    </label>
                                    <div class="layui-input-block" id="xiyan">
                                        {volist name="xiyan.children" id="data" key="i" }
                                            <input type="radio" name="xiyan_type_id" value="{$data.id}" {if isset($info['xiyan_type_id']) && $info['xiyan_type_id']== $data.id}checked{/if} title="{$data.name}">
                                        {/volist}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 250px;">
                                        <span style="margin-right: 30px;">（2）饮酒</span>过去一年是否规律饮酒
                                    </label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="yinjiu" value="是" title="是" {if isset($info['yinjiu']) && $info['yinjiu']== '是'}checked{/if}>
                                        <input type="radio" name="yinjiu" value="否" title="否" {if isset($info['yinjiu']) && $info['yinjiu']== '否'}checked{/if}>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        平均每周（7天）饮酒
                                        <input value="{if isset($info['yinjiu_nums'])}{$info['yinjiu_nums']}{/if}" type="text"  name="yinjiu_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        次
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 100px;margin-left: 30px;">
                                        常饮酒为
                                    </label>
                                    <div class="layui-input-block" id="yinjiu">
                                        <input hidden value="{if isset($info['jiulist'])}{$info['jiulist']}{/if}" type="text" name="jiulist" value="" disabled>
                                        {volist name="yinjiu.children" id="data" key="i" }
                                        <input type="checkbox" lay-filter="jiulist" value="{$data.id}" title="{$data.name}">
                                        {/volist}
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item">
                                    <div class="layui-input-block" style="margin-left: 90px;">
                                        啤酒
                                        <input value="{if isset($info['pijiu_nums'])}{$info['pijiu_nums']}{/if}" type="text"  name="pijiu_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        斤/周；葡萄酒/黄酒
                                        <input value="{if isset($info['putao_huangjiu_nums'])}{$info['putao_huangjiu_nums']}{/if}" type="text"  name="putao_huangjiu_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        斤/周； 高度白酒
                                        <input value="{if isset($info['baijiu_nums'])}{$info['baijiu_nums']}{/if}" type="text"  name="baijiu_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        两/周
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 330px;">
                                        <span style="margin-right: 30px;">（3）喝茶</span>在您过去的一年中是否经常喝茶叶茶
                                    </label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="cha" value="是" title="是" {if isset($info['cha']) && $info['cha']== '是'}checked{/if}>
                                        <input type="radio" name="cha" value="否" title="否" {if isset($info['cha']) && $info['cha']== '否'}checked{/if}>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        平均每周（7天）泡茶
                                        <input value="{if isset($info['cha_nums'])}{$info['cha_nums']}{/if}" type="text"  name="cha_nums" autocomplete="off" class="layui-input" style="display:inline;width: 100px;">
                                        次（换一次茶叶算一次）
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 170px;margin-left: 30px;">
                                        常喝茶为（可多选）
                                    </label>
                                    <div class="layui-input-block" id="hecha">
                                        <input hidden value="{if isset($info['cha_list'])}{$info['cha_list']}{/if}" type="text" name="cha_list" value="" disabled>
                                        {volist name="hecha.children" id="data" key="i" }
                                        <input type="checkbox" lay-filter="cha_list" value="{$data.id}" title="{$data.name}">
                                        {/volist}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">5、生活地</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <div class="layui-input-block" style="margin-left: 30px;" id="shenghuodi">
                                    {volist name="shenghuodi.children" id="data" key="i" }
                                    <input type="radio" name="area_id" value="{$data.id}" {if isset($info['area_id']) && $info['area_id']== $data.id}checked{/if} title="{$data.name}">
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div style="font-weight: 600;">6、联系电话</div>
                        <div class="layui-col-md12">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width: 100px;">本人移动电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['my_mobile'])}{$info['my_mobile']}{/if}" type="text" name="my_mobile" lay-verify="" autocomplete="off" placeholder="请输入本人移动电话"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">配偶移动电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['wife_mobile'])}{$info['wife_mobile']}{/if}" type="text" name="wife_mobile" lay-verify="" autocomplete="off" placeholder="请输入配偶移动电话"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">家庭电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['tel'])}{$info['tel']}{/if}" type="text" name="tel" lay-verify="" id="tel" autocomplete="off" placeholder="请输入家庭电话" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-col-md12">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">儿子移动电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['son_mobile'])}{$info['son_mobile']}{/if}" type="text" name="son_mobile" lay-verify="" autocomplete="off" placeholder="请输入儿子移动电话"  style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">儿子家庭电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['son_tel'])}{$info['son_tel']}{/if}" type="text" name="son_tel" lay-verify="" autocomplete="off" placeholder="请输入儿子家庭电话" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-col-md12">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">女儿移动电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['nver_mobile'])}{$info['nver_mobile']}{/if}" type="text" name="nver_mobile" lay-verify="" autocomplete="off" placeholder="请输入女儿移动电话" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">女儿家庭电话</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['nver_tel'])}{$info['nver_tel']}{/if}" type="text" name="nver_tel" lay-verify="" autocomplete="off" placeholder="女儿家庭电话" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-col-md12">
                            <div class="layui-col-md8">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">家庭住址</label>
                                    <div class="layui-input-block" style="width: 100%;">
                                        <input value="{if isset($info['address'])}{$info['address']}{/if}" type="text" name="address" lay-verify="required" style="width: 80%;" autocomplete="off" placeholder="请输入家庭住址" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"  style="width: 100px;">邮政编码</label>
                                    <div class="layui-input-block">
                                        <input value="{if isset($info['zipcode'])}{$info['zipcode']}{/if}" type="text" name="zipcode" lay-verify="required" autocomplete="off" placeholder="请输入邮政编码" style="width: auto;" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">7、教育程度</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <div class="layui-input-block" style="margin-left: 30px;" id="jiaoyuchengdu">
                                    {volist name="jiaoyuchengdu.children" id="data" key="i" }
                                    <input type="radio" name="jiaoyu_id" value="{$data.id}" {if isset($info['jiaoyu_id']) && $info['jiaoyu_id']== $data.id}checked{/if} title="{$data.name}">
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">8、目前职业</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <div class="layui-input-block" style="margin-left: 30px;" id="muqianzhiye">
                                    {volist name="muqianzhiye.children" id="data" key="i" }
                                    <input type="radio" name="zhiye_id" value="{$data.id}" {if isset($info['zhiye_id']) && $info['zhiye_id']== $data.id}checked{/if} title="{$data.name}">
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">9、婚姻状态</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <div class="layui-input-block" style="margin-left: 30px;" id="hunyinzhuangtai">
                                    {volist name="hunyinzhuangtai.children" id="data" key="i" }
                                    <input type="radio" name="hunyin_id" value="{$data.id}" {if isset($info['hunyin_id']) && $info['hunyin_id']== $data.id}checked{/if} title="{$data.name}">
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" style="margin-top: 20px;">
                        <div style="font-weight: 600;">10、民族</div>
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <div class="layui-input-block" style="margin-left: 30px;" id="minzu">
                                    {volist name="minzu.children" id="data" key="i" }
                                    <input type="radio" name="minzu_id" value="{$data.id}" {if isset($info['minzu_id']) && $info['minzu_id']== $data.id}checked{/if} title="{$data.name}">
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>
                </fieldset>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            {if empty($info['id'])}
                            <button class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            {else /}
                            <button class="layui-btn" lay-submit="" lay-filter="next">下一步</button>
                            {/if}
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>


<script src="__STATIC__/layuikn/layui/layui.js"></script>
<script>
    layui.config({
        base: '__STATIC__/layuikn/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
        ,ajaxData:'../extends/ajaxData'
        ,getOption:'../extends/getOption'
    }).use(['index', 'jquery', 'ajaxData', 'getOption', 'form', 'laydate'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,ajaxData = layui.ajaxData
            ,getOption = layui.getOption
            ,form = layui.form;

        var id = "{if isset($info.id)}{$info.id}{/if}";
        if(id === ''){
            sessionStorage.setItem('pid', null);
        }
        laydate.render({
            elem: '#birthday' //指定元素
        });

        laydate.render({
            elem: '#rydate' //指定元素
        });

        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#LAY-component-form-group-date'
        });

        /* 自定义验证规则 */
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });


        //监听复选框
        form.on('checkbox(bingshi)', function (data) {
            var number = $('input[name="bingshi"]'), value = data.value, array = number.val().split(",");
            if (data.elem.checked) {

                number.val(number.val() + value + ",");
            } else {
                var newnumber = "";
                for (var i = 0; i < array.length; i++) {
                    var str = array[i];
                    newnumber += (str != value && str != "" && str != null) ? str + "," : "";
                }
                number.val(newnumber);
            }
        });

        form.on('checkbox(jiulist)', function (data) {
            var number = $('input[name="jiulist"]'), value = data.value, array = number.val().split(",");
            if (data.elem.checked) {

                number.val(number.val() + value + ",");
            } else {
                var newnumber = "";
                for (var i = 0; i < array.length; i++) {
                    var str = array[i];
                    newnumber += (str != value && str != "" && str != null) ? str + "," : "";
                }
                number.val(newnumber);
            }
        });

        form.on('checkbox(cha_list)', function (data) {
            var number = $('input[name="cha_list"]'), value = data.value, array = number.val().split(",");
            if (data.elem.checked) {

                number.val(number.val() + value + ",");
            } else {
                var newnumber = "";
                for (var i = 0; i < array.length; i++) {
                    var str = array[i];
                    newnumber += (str != value && str != "" && str != null) ? str + "," : "";
                }
                number.val(newnumber);
            }
        });
        initbingshiValue();
        initjiulistValue();
        initcha_listValue();
        function initbingshiValue() {
            var param=$("input[name='bingshi']").val(),checkBoxs = $("input[type='checkbox']"), array = param.split(",");
            for (var i = 0; i < array.length; i++) {
                for (var j = 0; j < checkBoxs.length; j++) {
                    var checkbox = $(checkBoxs[j]);
                    if (checkbox.val() == array[i]) {
                        checkbox.attr('checked','checked');
                        break;
                    }
                }
            }
            form.render('checkbox');
        }

        function initjiulistValue() {
            var param=$("input[name='jiulist']").val(),checkBoxs = $("input[type='checkbox']"), array = param.split(",");
            for (var i = 0; i < array.length; i++) {
                for (var j = 0; j < checkBoxs.length; j++) {
                    var checkbox = $(checkBoxs[j]);
                    if (checkbox.val() == array[i]) {
                        checkbox.attr('checked','checked');
                        break;
                    }
                }
            }
            form.render('checkbox');
        }

        function initcha_listValue() {
            var param=$("input[name='cha_list']").val(),checkBoxs = $("input[type='checkbox']"), array = param.split(",");
            for (var i = 0; i < array.length; i++) {
                for (var j = 0; j < checkBoxs.length; j++) {
                    var checkbox = $(checkBoxs[j]);
                    if (checkbox.val() == array[i]) {
                        checkbox.attr('checked','checked');
                        break;
                    }
                }
            }
            form.render('checkbox');
        }

        /* 监听指定开关 */
        form.on('switch(component-form-switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });
        ;
        /* 监听提交 */
        form.on('submit(submit)', function(data){
            var url = "{:url('patient/add',[])}";
            if(id != ''){
                url = "{:url('patient/update',[])}?id=" + id;
                data.field.id = id;
            }
            data.field.yyname = $('select[name="yyid"]').find('option:selected').text();
            data.field.keshi = $('select[name="ksid"]').find('option:selected').text();
            data.field.area = $('input[name="area_id"]:checked').attr('title')
            data.field.xiyan_type = $('input[name="xiyan_type_id"]:checked').attr('title');
            data.field.jiaoyu = $('input[name="jiaoyu_id"]:checked').attr('title');
            data.field.zhiye = $('input[name="zhiye_id"]:checked').attr('title');
            data.field.hunyin = $('input[name="hunyin_id"]:checked').attr('title');
            data.field.minzu = $('input[name="minzu_id"]:checked').attr('title');
            ajaxData.ajaxData('POST', url, data.field,function (back) {
                var msg = "新增成功";
                if(id != ''){
                    msg = "修改成功";
                }
                if(back.code == 200){
                    layer.msg(msg, { icon: 6, time: 1000 }, function () {
                        // 获得frame索引
                        location.reload();
                    });
                }else{
                    layer.msg(back.msg, {icon: 5});
                }
            });
            // parent.layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // })
            return false;
        });

        form.on('submit(next)', function(data){

            var url = "{:url('patient/update',[])}?id=" + id;
            data.field.id = id;
            data.field.yyname = $('select[name="yyid"]').find('option:selected').text();
            data.field.keshi = $('select[name="ksid"]').find('option:selected').text();
            data.field.area = $('input[name="area_id"]:checked').attr('title')
            data.field.xiyan_type = $('input[name="xiyan_type_id"]:checked').attr('title');
            data.field.jiaoyu = $('input[name="jiaoyu_id"]:checked').attr('title');
            data.field.zhiye = $('input[name="zhiye_id"]:checked').attr('title');
            data.field.hunyin = $('input[name="hunyin_id"]:checked').attr('title');
            data.field.minzu = $('input[name="minzu_id"]:checked').attr('title');
            ajaxData.ajaxData('POST', url, data.field,function (back) {
                // var msg = "新增成功";
                // if(id != ''){
                //     msg = "修改成功";
                // }
                if(back.code == 200){
                    window.location.href = "{:url('jibing/show',[])}?pid=" + id;
                }else{
                    layer.msg(back.msg, {icon: 5});
                }
            });
            // parent.layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // })
            return false;
        });
    });
</script>
</body>
</html>
